<?php

namespace app\validate;

use think\Validate;

class Login extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'wechat'=>['require','regex'=>'/^[0-9]*$/'],
        'ali'=>['require','regex'=>'/^[A-Z0-9]{32}$/'],
        'phone'=>['require','regex'=>'/^[1]([3-9])[0-9]{9}$/'],
        'code'=>['require','regex'=>'/^[0-9]{6}$/'],
        'password'=>['require','regex'=>'/^[\w_-]{6,16}$/'],
        'email'=>['email'],
        'username'=>['require','regex'=>'/^(?=.*[a-zA-Z])[a-zA-Z0-9_-]{6,16}$/'],
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'wechat' => 'appid错误',
        'ali' => 'appid错误',
        'phone' => '请输入正确的手机号',
        'password'=> '密码为6-15位字母、数字、下划线',
        'code'=> '请输入6位手机验证码',
    ];
    protected $scene = [
        'ali'  =>  ['ali'],
        'wechat'  =>  ['wechat'],
        'phone'  =>  ['phone','code'],
        'password'  =>  ['phone','password'],
        'username'  =>  ['username','password'],
        'email'  =>  ['email','password'],
    ];
}
